package day9;

import lombok.SneakyThrows;

class thr{
    int count = 1;

    public void show() throws InterruptedException {
        synchronized (Object.class) {
            Thread.sleep(3000);
            System.out.println(Thread.currentThread().getName() + "过山洞");

        }
    }
}

class thr2 extends Thread{
    public thr2 (String name) {
        super(name);
    }

    @Override
    public void run() {
        synchronized (Object.class) {
            try {
                Thread.sleep(3000);
                System.out.println(Thread.currentThread().getName() + "过山洞");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

public class Demo5 {

    public static void main(String[] args) {
//        for (int i = 0; i < 10; i++) {
//            final thr s = new thr();
//            new Thread("玩家" + i) {
//                @Override
//                public void run() {
//                    try {
//                        s.show();
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }.start();
//        }

        for (int i = 0; i < 10; i++) {
            new thr2("玩家" + i).start();
        }
    }

}
